package com.course.controller;

import com.course.component.http.Crp;
import com.course.component.http.requ.RequestToken;
import com.course.dto.reqs.RequestRole;
import com.course.masterservice.MasterLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/x")
public class HomeController {
    @Autowired
    private MasterLoginService loginService;

    @PostMapping("token")
    public Crp token(@RequestBody RequestToken token) {
        return Crp.success(loginService.login(token));
    }

    //自己的额
    @PostMapping("menu")
    public Crp menu() {
        return Crp.success(loginService.getMenu());
    }

    //所有的
    @PostMapping("menu/all")
    public Crp menuAll() {
        return Crp.success(loginService.getMenuAll());
    }

    //role
    @PostMapping("menu/role")
    public Crp menuRole(@RequestBody RequestRole requestRole) {
        return Crp.success(loginService.getMenuRole(requestRole));
    }

    //role
    @PostMapping("menu/link")
    public Crp menuLink(@RequestBody RequestRole requestRole) {
        return Crp.success(loginService.getMenuRole(requestRole));
    }

    @GetMapping("version")
    public Crp version() {
        return Crp.success(loginService.getVersion());
    }

    @GetMapping("user")
    public Crp user() {
        return Crp.success(loginService.getLoginUser());
    }


}
